The Foldable Typeclass in Haskell

Foldable is the typeclass for data structures whose elements can be summarized by traversing and combining them.

  class Foldable t where
    foldMap :: Monoid m => (a -> m) -> t a -> m
    foldr :: (a -> b -> b) -> b -> t a -> b

  {-# MINIMAL foldMap | foldr #-}

Date: 2026-07-31 Fri

Author: ArcaLunar